﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YLW.Plat.Jhfw.HL7V3.XSDModels.QUMT_IN020040UV01_Sxsq;
using YLW.Plat.Jhfw.Model.JhfwSxsqd;

namespace YLW.Plat.Jhfw.HL7V3.V3Message
{
    public class V3_QUMT_IN020040UV01_Sxsq
    {
        public static string BloodTransAppInfoQuery_Response(GetJhfwSxsqdListOut jsonData, string id_extension, string sender_name, string receiver_name)
        {
            string hl7Xml = string.Empty;

            if (jsonData == null)
            {
                return hl7Xml;
            }

            //根据XML XSD构建HL7 XML消息格式

            //创建根对象
            var xmlRoot = new QUMT_IN020040UV01
            {
                ITSVersion = "XML_1.0",
                id = new id { root = "2.16.156.10011.2.5.1.1", extension = Guid.NewGuid().ToString() },
                creationTime = new creationTime { value = DateTime.Now.ToString("yyyyMMddHHmmss") },
                interactionId = new interactionId { root = "2.16.156.10011.2.5.1.2", extension = "QUMT_IN020040UV01" },
                processingCode = new processingCode { code = "P" },
                processingModeCode = new processingModeCode(),
                acceptAckCode = new acceptAckCode { code = "AL" },
                receiver = new receiver
                {
                    typeCode = "RCV",
                    device1 = new device1
                    {
                        classCode = "DEV",
                        determinerCode = "INSTANCE",
                        id = new id
                        {
                            root = "2.16.156.10011.2.5.1.3",
                            extension = receiver_name
                        }
                    }
                },
                sender = new sender
                {
                    typeCode = "SND",
                    device1 = new device1
                    {
                        classCode = "DEV",
                        determinerCode = "INSTANCE",
                        id = new id
                        {
                            root = "2.16.156.10011.2.5.1.3",
                            extension = sender_name
                        }
                    }
                },
                acknowledgement = new acknowledgement
                {
                    typeCode = jsonData.subcode == "success" ? "AA" : "AE",
                    targetMessage = new targetMessage
                    {
                        id = new id
                        {
                            root = "2.16.156.10011.2.5.1.1",
                            extension = id_extension
                        }
                    },
                    acknowledgementDetail = new acknowledgementDetail
                    {
                        text = new text
                        {
                            value = jsonData.submsg
                        }
                    }
                },
                controlActProcess = new controlActProcess
                {
                    classCode = "CACT",
                    moodCode = "EVN",

                    queryAck = new queryAck
                    {
                        queryResponseCode = new queryResponseCode { code = jsonData.subcode == "success" ? "OK" : "error" },
                    }
                },
            };

            List<subject> subList = new List<subject>();

            if (jsonData != null && jsonData.data != null)
            {
                foreach (var listItem in jsonData.data)
                {
                    //性别
                    string sexCode = "";
                    string sexName = "";
                    switch (listItem.psex)
                    {
                        case "B":
                            sexCode = "9";
                            sexName = "未说明的性别";
                            break;
                        case "F":
                            sexCode = "2";
                            sexName = "女性";
                            break;
                        case "M":
                            sexCode = "1";
                            sexName = "男性";
                            break;
                        case "U":
                            sexCode = "0";
                            sexName = "未知的性别";
                            break;
                    }

                    subList.Add(new subject
                    {
                        typeCode = "SUBJ",
                        procedureRequest = new procedureRequest
                        {
                            classCode = "PROC",
                            moodCode = "RQO",
                            id = new id
                            {
                                item = new item[]
                                    {
                                        new item{
                                            root="2.16.156.10011.1.24",
                                            extension=listItem.sqdh
                                        }
                                    }
                            },
                            code = new code(),
                            text = new text
                            {
                                value = listItem.sqdmc
                            },
                            statusCode = new statusCode(),
                            effectiveTime = new effectiveTime
                            {
                                low = new low { value = listItem.sqrq }
                            },
                            priorityCode = new priorityCode
                            {
                                code = listItem.yxjdm,
                                displayName = new displayName { value = listItem.yxjmc }
                            },
                            author = new author
                            {
                                typeCode = "AUT",
                                time = new time
                                {
                                    value = listItem.kdrq
                                },
                                assignedEntity = new assignedEntity
                                {
                                    classCode = "ASSIGNED",
                                    id = new id
                                    {
                                        item = new item[]
                                            {
                                                new item
                                                {
                                                    root="2.16.156.10011.1.4",
                                                    extension=listItem.kdysdm
                                                }
                                            }
                                    },
                                    assignedPerson = new assignedPerson
                                    {
                                        classCode = "PSN",
                                        determinerCode = "INSTANCE",
                                        name = new name
                                        {
                                            item = new item
                                            {
                                                part = new part { value = listItem.kdysxm }
                                            }
                                        }
                                    },
                                    representedOrganization = new representedOrganization
                                    {
                                        classCode = "ORG",
                                        determinerCode = "INSTANCE",
                                        id = new id
                                        {
                                            item = new item[]
                                            {
                                                new item
                                                {
                                                    root="2.16.156.10011.2.3.2.62",
                                                    extension=listItem.kdksdm
                                                }
                                            }
                                        },
                                        name = new name
                                        {
                                            item = new item
                                            {
                                                part = new part { value = listItem.kdksmc }
                                            }
                                        }
                                    }
                                }
                            },
                            verifier = new verifier
                            {
                                typeCode = "VRF",
                                time = new time
                                {
                                    value = listItem.shrq
                                },
                                assignedEntity = new assignedEntity
                                {
                                    classCode = "ASSIGNED",
                                    id = new id
                                    {
                                        item = new item[]
                                            {
                                                new item
                                                {
                                                    root="2.16.156.10011.1.4",
                                                    extension=listItem.shrdm
                                                }
                                            }
                                    },
                                    assignedPerson = new assignedPerson
                                    {
                                        classCode = "PSN",
                                        determinerCode = "INSTANCE",
                                        name = new name
                                        {
                                            item = new item
                                            {
                                                part = new part { value = listItem.shrxm }
                                            }
                                        }
                                    }
                                }
                            },
                            pertinentInformation = new pertinentInformation
                            {
                                typeCode = "SUBJ",
                                contextConductionInd = true,
                                organizer = new organizer
                                {
                                    classCode = "CONTAINER",
                                    moodCode = "EVN",
                                    component = new component[]
                                    {
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="01",
                                                    Item=new originalText{ value="患者ABO血型" }
                                                },
                                                value=new value
                                                {
                                                    code=listItem.aboxx,
                                                    codeSystem="2.16.156.10011.2.3.1.85",
                                                    codeSystemName="ABO血型代码表",
                                                    displayName=new displayName[]
                                                    {
                                                        new displayName{ value=""}
                                                    }
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="02",
                                                    Item=new originalText{ value="患者Rh血型" }
                                                },
                                                value=new value
                                                {
                                                    code=listItem.rhxx,
                                                    codeSystem="2.16.156.10011.2.3.1.250",
                                                    codeSystemName="Rh（D）血型代码表",
                                                    displayName=new displayName[]
                                                    {
                                                        new displayName{ value=""}
                                                    }
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="03",
                                                    Item=new originalText{ value="身高" }
                                                },
                                                value=new value
                                                {
                                                    value1=listItem.height,
                                                    unit="cm"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="04",
                                                    Item=new originalText{ value="体重" }
                                                },
                                                value=new value
                                                {
                                                    value1=listItem.weight,
                                                    unit="kg"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="05",
                                                    Item=new originalText{ value="收缩压" }
                                                },
                                                value=new value
                                                {
                                                   value1=listItem.ssy,
                                                    unit="mmHg"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="06",
                                                    Item=new originalText{ value="舒张压" }
                                                },
                                                value=new value
                                                {
                                                   value1=listItem.szy,
                                                    unit="mmHg"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="07",
                                                    Item=new originalText{ value="体温" }
                                                },
                                                value=new value
                                                {
                                                    value1=listItem.tw,
                                                    unit="℃"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="08",
                                                    Item=new originalText{ value="脉搏" }
                                                },
                                                value=new value
                                                {
                                                    value1=listItem.mb,
                                                    unit="次/分"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="09",
                                                    Item=new originalText{ value="申请ABO血型" }
                                                },
                                                value=new value
                                                {
                                                    code=listItem.sqaboxx,
                                                    codeSystem="2.16.156.10011.2.3.1.85",
                                                    codeSystemName="ABO血型代码表",
                                                    displayName=new displayName[]
                                                    {
                                                        new displayName{ value=""}
                                                    }
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="10",
                                                    Item=new originalText{ value="申请Rh血型" }
                                                },
                                                value=new value
                                                {
                                                    code=listItem.sqrhxx,
                                                    codeSystem="2.16.156.10011.2.3.1.250",
                                                    codeSystemName="Rh（D）血型代码表",
                                                    displayName=new displayName[]
                                                    {
                                                        new displayName{ value=""}
                                                    }
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="11",
                                                    Item=new originalText{ value="采血标记" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.cxbj
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="12",
                                                    Item=new originalText{ value="输血地点" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxdd
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="13",
                                                    Item=new originalText{ value="输血目的" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxmd
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="14",
                                                    Item=new originalText{ value="输血性质" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxxz
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="15",
                                                    Item=new originalText{ value="输血紧急标志" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxjjbj
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="16",
                                                    Item=new originalText{ value="疾病史（含外伤）" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.jbmc
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="17",
                                                    Item=new originalText{ value="输血史" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxs
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="18",
                                                    Item=new originalText{ value="输血反应史" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.sxfys
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="19",
                                                    Item=new originalText{ value="药物过敏史" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.ywgms
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="20",
                                                    Item=new originalText{ value="孕次" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.yc,
                                                    unit="次"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="21",
                                                    Item=new originalText{ value="产次" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.cc,
                                                    unit="次"
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="22",
                                                    Item=new originalText{ value="其他重要病史" }
                                                },
                                                value=new value
                                                {
                                                    value1= listItem.qtjbbs
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="OBS",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="23",
                                                    Item=new originalText{ value="备注" }
                                                },
                                                value=new value
                                                {
                                                     value1= listItem.remark
                                                }
                                            }
                                        },
                                        new component
                                        {
                                            typeCode="COMP",
                                            observation=new observation
                                            {
                                                classCode="GEN",
                                                moodCode="EVN",
                                                code=new code
                                                {
                                                    code1="24",
                                                    Item=new originalText{ value="血量" }
                                                },
                                                value=new value
                                                {
                                                     value1= listItem.sl,
                                                     unit=listItem.sldw
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            componentOf1 = new componentOf1
                            {
                                contextConductionInd = false,
                                typeCode = "COMP",
                                encounter = new encounter
                                {
                                    classCode = "ENC",
                                    moodCode = "EVN",
                                    id = new id
                                    {
                                        item = new item[]
                                            {
                                                new item
                                                {
                                                    root="2.16.156.10011.2.5.1.8",
                                                    extension=listItem.series
                                                },
                                                new item
                                                {
                                                    root="2.16.156.10011.2.5.1.9",
                                                    extension=listItem.jzlsh
                                                }
                                            }
                                    },
                                    code = new code
                                    {
                                        code1 = listItem.stay,
                                        codeSystem = "2.16.156.10011.2.3.1.271",
                                        codeSystemName = "患者类型代码",
                                        Item = new displayName
                                        {
                                            value = ""
                                        }
                                    },
                                    statusCode = new statusCode(),
                                    subject = new subject
                                    {
                                        typeCode = "SBJ",
                                        patient = new patient
                                        {
                                            classCode = "PAT",
                                            id = new id
                                            {
                                                item = new item[]
                                                    {
                                                        new item
                                                        {
                                                            root="2.16.156.10011.2.5.1.5",
                                                            extension=""
                                                        },
                                                        new item
                                                        {
                                                            root="2.16.156.10011.2.5.1.4",
                                                            extension=listItem.mrn
                                                        },
                                                        new item
                                                        {
                                                            root="2.16.156.10011.1.10",
                                                            extension=listItem.jzlsh
                                                        },
                                                        new item
                                                        {
                                                            root="2.16.156.10011.1.12",
                                                            extension=""
                                                        }
                                                    }
                                            },
                                            patientPerson = new patientPerson
                                            {
                                                classCode = "PSN",
                                                id = new id
                                                {
                                                    item = new item[]
                                                        {
                                                            new item
                                                            {
                                                                root="2.16.156.10011.1.3",
                                                                extension=listItem.pcid
                                                            },
                                                            new item
                                                            {
                                                                root="2.16.156.10011.1.15",
                                                                extension=listItem.ybkh
                                                            }
                                                        }
                                                },
                                                name = new name
                                                {
                                                    item = new item
                                                    {
                                                        part = new part { value = listItem.pname }
                                                    }
                                                },
                                                telecom = new telecom
                                                {
                                                    item = new item
                                                    {
                                                        value = listItem.pphone
                                                    }
                                                },
                                                administrativeGenderCode = new administrativeGenderCode
                                                {
                                                    code = sexCode,
                                                    codeSystem = "2.16.156.10011.2.3.3.4"
                                                },
                                                birthTime = new birthTime
                                                {
                                                    value = listItem.pbirthday,
                                                    originalText = new originalText
                                                    {
                                                        value = ""
                                                    }
                                                },
                                                addr = new addr
                                                {
                                                    item = new item
                                                    {
                                                        use = "H",
                                                        part = new part
                                                        {
                                                            type = "AL",
                                                            value = listItem.paddress
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    location = new location
                                    {
                                        typeCode = "LOC",
                                        time = new time(),
                                        serviceDeliveryLocation = new serviceDeliveryLocation
                                        {
                                            classCode = "SDLOC",
                                            location = new location
                                            {
                                                classCode = "PLC",
                                                determinerCode = "INSTANCE",
                                                Items = new object[]
                                                    {
                                                        new id
                                                        {
                                                            item=new item[]
                                                            {
                                                                new item
                                                                {
                                                                    extension=listItem.bedid
                                                                }
                                                            }
                                                        },
                                                        new name
                                                        {
                                                            item=new item
                                                            {
                                                                use="IDE",
                                                                part=new part{ value="" }
                                                            }
                                                        },
                                                        new asLocatedEntityPartOf
                                                        {
                                                            classCode="LOCE",
                                                            location=new location
                                                            {
                                                                classCode="PLC",
                                                                determinerCode="INSTANCE",
                                                                Items=new object[]
                                                                {
                                                                    new id{
                                                                        item=new item[]{
                                                                            new item
                                                                            {
                                                                                extension=listItem.bfh
                                                                            }
                                                                        }
                                                                    },
                                                                    new name
                                                                    {
                                                                        item=new item
                                                                        {
                                                                            use="IDE",
                                                                            part=new part{ value="" }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                            },
                                            serviceProviderOrganization = new serviceProviderOrganization
                                            {
                                                classCode = "ORG",
                                                determinerCode = "INSTANCE",
                                                id = new id
                                                {
                                                    item = new item[]
                                                        {
                                                            new item{ extension=listItem.zyksdm }
                                                        }
                                                },
                                                name = new name
                                                {
                                                    item = new item
                                                    {
                                                        use = "IDE",
                                                        part = new part { value = listItem.zyksmc }
                                                    }
                                                },
                                                asOrganizationPartOf = new asOrganizationPartOf
                                                {
                                                    classCode = "PART",
                                                    wholeOrganization = new wholeOrganization
                                                    {
                                                        classCode = "ORG",
                                                        determinerCode = "INSTANCE",
                                                        id = new id
                                                        {
                                                            item = new item[]
                                                                {
                                                                    new item{ extension=listItem.zybqdm }
                                                                }
                                                        },
                                                        name = new name
                                                        {
                                                            item = new item
                                                            {
                                                                use = "IDE",
                                                                part = new part { value = listItem.zybqmc }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            extension = new extension
                            {
                                sjly = new sjly { value = new value { Text = new string[] { listItem.sjly } } },
                                lyxt = new lyxt { value = new value { Text = new string[] { listItem.lyxt } } },
                                hoscode = new hoscode { value = new value { Text = new string[] { listItem.hoscode } } },
                                sqdh = new sqdh { value = new value { Text = new string[] { listItem.sqdh } } },
                                yzid = new yzid { value = new value { Text = new string[] { listItem.yzid } } },
                                jzlsh = new jzlsh { value = new value { Text = new string[] { listItem.jzlsh } } },
                                mrn = new mrn { value = new value { Text = new string[] { listItem.mrn } } },
                                pname = new pname { value = new value { Text = new string[] { listItem.pname } } },
                                pcid = new pcid { value = new value { Text = new string[] { listItem.pcid } } },
                                pbirthday = new pbirthday { value = new value { Text = new string[] { listItem.pbirthday } } },
                                psex = new psex { value = new value { Text = new string[] { listItem.psex } } },
                                pphone = new pphone { value = new value { Text = new string[] { listItem.pphone } } },
                                page = new page { value = new value { Text = new string[] { listItem.page.ToString() } } },
                                pageunit = new pageunit { value = new value { Text = new string[] { listItem.pageunit.ToString() } } },
                                paddress = new paddress { value = new value { Text = new string[] { listItem.paddress } } },
                                ybkh = new ybkh { value = new value { Text = new string[] { listItem.ybkh } } },
                                series = new series { value = new value { Text = new string[] { listItem.series } } },
                                stay = new stay { value = new value { Text = new string[] { listItem.stay } } },
                                zyksdm = new zyksdm { value = new value { Text = new string[] { listItem.zyksdm } } },
                                zyksmc = new zyksmc { value = new value { Text = new string[] { listItem.zyksmc } } },
                                zybqdm = new zybqdm { value = new value { Text = new string[] { listItem.zybqdm } } },
                                zybqmc = new zybqmc { value = new value { Text = new string[] { listItem.zybqmc } } },
                                bedid = new bedid { value = new value { Text = new string[] { listItem.bedid } } },
                                bfh = new bfh { value = new value { Text = new string[] { listItem.bfh } } },
                                aboxx = new aboxx { value = new value { Text = new string[] { listItem.aboxx } } },
                                rhxx = new rhxx { value = new value { Text = new string[] { listItem.rhxx } } },
                                height = new height { value = new value { Text = new string[] { listItem.height.ToString() } } },
                                weight = new weight { value = new value { Text = new string[] { listItem.weight.ToString() } } },
                                szy = new szy { value = new value { Text = new string[] { listItem.szy.ToString() } } },
                                ssy = new ssy { value = new value { Text = new string[] { listItem.ssy.ToString() } } },
                                mb = new mb { value = new value { Text = new string[] { listItem.mb } } },
                                tw = new tw { value = new value { Text = new string[] { listItem.tw } } },
                                sxs = new sxs { value = new value { Text = new string[] { listItem.sxs } } },
                                sxfys = new sxfys { value = new value { Text = new string[] { listItem.sxfys } } },
                                bsxx = new bsxx { value = new value { Text = new string[] { listItem.bsxx } } },
                                ywgms = new ywgms { value = new value { Text = new string[] { listItem.ywgms } } },
                                qtjbbs = new qtjbbs { value = new value { Text = new string[] { listItem.qtjbbs } } },
                                yc = new yc { value = new value { Text = new string[] { listItem.yc } } },
                                cc = new cc { value = new value { Text = new string[] { listItem.cc } } },
                                sqaboxx = new sqaboxx { value = new value { Text = new string[] { listItem.sqaboxx } } },
                                sqrhxx = new sqrhxx { value = new value { Text = new string[] { listItem.sqrhxx } } },
                                sl = new sl { value = new value { Text = new string[] { listItem.sl.ToString() } } },
                                sldw = new sldw { value = new value { Text = new string[] { listItem.sldw } } },
                                cxbj = new cxbj { value = new value { Text = new string[] { listItem.cxbj } } },
                                sxjjbj = new sxjjbj { value = new value { Text = new string[] { listItem.sxjjbj } } },
                                sxmd = new sxmd { value = new value { Text = new string[] { listItem.sxmd } } },
                                sxxz = new sxxz { value = new value { Text = new string[] { listItem.sxxz } } },
                                sxdd = new sxdd { value = new value { Text = new string[] { listItem.sxdd } } },
                                yxjdm = new yxjdm { value = new value { Text = new string[] { listItem.yxjdm } } },
                                yxjmc = new yxjmc { value = new value { Text = new string[] { listItem.yxjmc } } },
                                remark = new remark { value = new value { Text = new string[] { listItem.remark } } },
                                sqrq = new sqrq { value = new value { Text = new string[] { listItem.sqrq } } },
                                kdksdm = new kdksdm { value = new value { Text = new string[] { listItem.kdksdm } } },
                                kdksmc = new kdksmc { value = new value { Text = new string[] { listItem.kdksmc } } },
                                kdysdm = new kdysdm { value = new value { Text = new string[] { listItem.kdysdm } } },
                                kdysxm = new kdysxm { value = new value { Text = new string[] { listItem.kdysxm } } },
                                kdrq = new kdrq { value = new value { Text = new string[] { listItem.kdrq } } },
                                jbdm = new jbdm { value = new value { Text = new string[] { listItem.jbdm } } },
                                jbmc = new jbmc { value = new value { Text = new string[] { listItem.jbmc } } },
                                zdlbdm = new zdlbdm { value = new value { Text = new string[] { listItem.zdlbdm } } },
                                zdlbmc = new zdlbmc { value = new value { Text = new string[] { listItem.zdlbmc } } },
                                zdrq = new zdrq { value = new value { Text = new string[] { listItem.zdrq } } },
                                shrdm = new shrdm { value = new value { Text = new string[] { listItem.shrdm } } },
                                shrxm = new shrxm { value = new value { Text = new string[] { listItem.shrxm } } },
                                shrq = new shrq { value = new value { Text = new string[] { listItem.shrq } } },
                                zxksdm = new zxksdm { value = new value { Text = new string[] { listItem.zxksdm } } },
                                zxksmc = new zxksmc { value = new value { Text = new string[] { listItem.zxksmc } } },
                                zxsj = new zxsj { value = new value { Text = new string[] { listItem.zxsj } } },
                                sqdmc = new sqdmc { value = new value { Text = new string[] { listItem.sqdmc } } },
                                sqdzt = new sqdzt { value = new value { Text = new string[] { listItem.sqdzt } } },
                                useflag = new useflag { value = new value { Text = new string[] { listItem.useflag } } },
                                in_empid = new in_empid { value = new value { Text = new string[] { listItem.in_empid } } },
                                in_date = new in_date { value = new value { Text = new string[] { listItem.in_date } } },
                                xg_empid = new xg_empid { value = new value { Text = new string[] { listItem.xg_empid } } },
                                xgsj = new xgsj { value = new value { Text = new string[] { listItem.xgsj } } }
                            }
                        }
                    });
                }
            }

            xmlRoot.controlActProcess.subject = subList.ToArray();

            hl7Xml = HL7V3Helper.SerializeToXml(xmlRoot);

            return hl7Xml;
        }
    }
}
